<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>双窗口模板</title>
    <link href="../../../../resources/lib/bui/css/dpl-min.css"
          th:href="@{/resources/lib/bui/css/dpl-min.css}"
          rel="stylesheet" />
    <link href="../../../../resources/lib/bui/css/bui-min.css"
          th:href="@{/resources/lib/bui/css/bui-min.css}"
          rel="stylesheet" />
    <link href="../../../../resources/lib/bui/css/bui-min.css"
          th:href="@{/resources/lib/bui/css/layout-min.css}"
          rel="stylesheet" />
    <script src="../../../../resources/lib/bui/js/jquery-1.8.1.min.js"
            th:src="@{/resources/lib/bui/js/jquery-1.8.1.min.js}"></script>
    <script src="../../../../resources/lib/bui/js/bui-min.js"
            th:src="@{/resources/lib/bui/js/bui-min.js}"></script>
    <script src="../../../../resources/lib/jquery/jquery.form.min.js"
            th:src="@{/resources/lib/jquery/jquery.form.min.js}"></script>
    <script src="../../../../resources/lib/jquery/jquery.util.js"
            th:src="@{/resources/lib/jquery/jquery.util.js}"></script>
</head>
<body>
<div id="add" th:include="nh/template/addLinkDialog :: add" style="display: none;width:100%;height: 100%;"></div>
<div id="setting" th:include="nh/template/template_setting :: setting" style="display: none;width:100%;height: 100%;"></div>
<div class="demo-content">
    <style type="text/css">
        a{color:#fff;font-size: 24px;}
        a:visited{text-decoration:none; color:red;}
        a:hover{text-decoration:none; color:red;}
    </style>

    <script type="text/javascript">
        var winWidth = 0;
        var winHeight = 0;
        var control2_1 = null;
        var control2_2 = null;
        findDimensions2();
        //函数：获取尺寸
        function findDimensions2(){
            //获取窗口宽度
            if (window.innerWidth)
                winWidth = window.innerWidth;
            else if ((document.body) && (document.body.clientWidth))
                winWidth = document.body.clientWidth;
            //获取窗口高度
            if (window.innerHeight)
                winHeight = window.innerHeight;
            else if ((document.body) && (document.body.clientHeight))
                winHeight = document.body.clientHeight;
            //通过深入Document内部对body进行检测，获取窗口大小
            if (document.documentElement  && document.documentElement.clientHeight && document.documentElement.clientWidth)
            {
                winHeight = document.documentElement.clientHeight;
                winWidth = document.documentElement.clientWidth;
            }
            winHeight-=2;
            winWidth-=2;
            initLayout();
        }
        //初始化布局
        function initLayout(){
            BUI.use(['bui/layout','bui/grid','bui/data','bui/tree'],function (Layout,Grid,Data,Tree) {
                control2_1 = new BUI.Component.Controller({
                    width:winWidth,
                    height:winHeight/2,
                    // srcNode : '#div1',
                    elCls : 'ext-border-layout',
                    children : [{
                        xclass : 'controller',
                        layout : {
                            title : '<a href="javascript:void(0)" onclick="showDialog(control2_1,\'c2_1\',1,nodeId)">+</a>&nbsp;&nbsp;<span id="title1"></span>',
                            region : 'center',
                            fit : 'both'
                        },
                        id : 'c2_1',
                        content : ''
                    }],
                    plugins : [Layout.Border]
                }).render();
                control2_2 = new BUI.Component.Controller({
                    width:winWidth,
                    height:winHeight/2,
                    // srcNode : '#div1',
                    elCls : 'ext-border-layout',
                    children : [{
                        xclass : 'controller',
                        layout : {
                            title : '<a href="javascript:void(0)" onclick="showDialog(control2_2,\'c2_2\',2,nodeId)">+</a>&nbsp;&nbsp;<span id="title2"></span>',
                            region : 'center',
                            fit : 'both'
                        },
                        id : 'c2_2',
                        content : ''
                    }],
                    plugins : [Layout.Border]
                }).render();
                findInitInfor(nodeId);
            });
        }

        function choseTemplate(modelCount) {
            if (treeMenu != null) {
                if(treeMenu.title1!=null&&treeMenu.title1!=""){
                    $('#title1').html(treeMenu.title1);
                }
                if (treeMenu.modelUrl1 != null && treeMenu.modelUrl1 != "") {
                    var url = treeMenu.modelUrl1.split("|");
                    if (judgeLink(url[0])) {
                        control2_1.getChild('c2_1').set('content', '<iframe src=' + url[0] + ' height="100%" width="100%" scrolling=' + url[1] + '></iframe>');
                    } else if (judgeImg(url[0])) {
                        control2_1.getChild('c2_1').set('content', '<img src=' + url[0] + ' height="100%" width="100%">');
                    }
                }
                if(treeMenu.title2!=null&&treeMenu.title2!=""){
                    $('#title2').html(treeMenu.title2);
                }
                if (treeMenu.modelUrl2 != null && treeMenu.modelUrl2 != "") {
                    var url = treeMenu.modelUrl2.split("|");
                    if (judgeLink(url[0])) {
                        control2_2.getChild('c2_2').set('content', '<iframe src=' + url[0] + ' height="100%" width="100%" scrolling=' + url[1] + '></iframe>');
                    } else if (judgeImg(url[0])) {
                        control2_2.getChild('c2_2').set('content', '<img src=' + url[0] + ' height="100%" width="100%">');
                    }
                }
            }
            $('.x-border-title').css('padding','3px');
            $('.ext-border-layout').css('padding','0px');
        }
    </script>
</div>
</body>
</html>